/*
 * 
 * ....................................................................
 * ...######..#####.....##....####..#####..####..#####..######....##...
 * .....##....##..#....###...##.....##.....##....##..#....##.....###...
 * .....##....####....#.##....##....####...####..####.....##....#.##...
 * .....##....##.#...#####.....##...##.....##....##.#.....##...#####...
 * .....##....##..#.#...##..####....##.....####..##..#....##..#...##...
 * ....................................................................
 */

package ua.trasferta.common.utils;

import java.util.Calendar;
import java.util.Date;

import ua.trasferta.common.annotations.createBy;
import static ua.trasferta.common.team.TeamMember.*;

/**
 * <p>
 * Java utility class for routines with the date and time values.<br>
 * </p>
 * 
 * @author Anton Podviaznikov
 */
@createBy(authors = ANTON_PODVIAZNIKOV)
public final class Dates
{
	public static final String UKRAINIAN_DATE_PATTERN = "dd.MM.yy";
	public static final String UKRAINIAN_TIME_PATTERN = "HH:mm";
	public static final int QUARTAL_LENGTH = 4;

	/**
	 * Private constructor to avoid class instantiation.
	 */
	private Dates()
	{
		// hidden constructor.
	}

	/**
	 * Method finds number of the last month(January is 1).
	 * 
	 * @return number of the previous month.
	 */
	public static int getLastFullMonth()
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		int month = calendar.get(Calendar.MONTH);
		if (month == 0)
		{
			month = 12;
		}
		return month;
	}

	/**
	 * Method finds number of the quartal start month.
	 * 
	 * @return number of the start quartal month.
	 */
	public static int getStartPeriodMonth()
	{
		return Dates.getLastFullMonth() - Dates.QUARTAL_LENGTH;
	}

	/**
	 * Method finds current year.
	 * 
	 * @return current year.
	 */
	public static int getYear()
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		return calendar.get(Calendar.YEAR);
	}
}
